





####
proc get_violation_summary {vio_list_file} {
		set vio_cnt 0
		set vio_wns 0.000
		set vio_constrain 0.000
		set vio_value 0.000
		set vio_constrain_value 0.000

		set file [open $vio_list_file "r"]
		while {[gets $file line] >=0} {
				if {[regexp max_capacitance $line]} {
						set name MAX_CAPACITANCE
				} elseif {[regexp max_transition $line]} {
						set name MAX_TRANSITION
				}

				if {[regexp VIOLATED $line]} {
						set vio_value [lindex $line 3]
						set vio_constrain_value [lindex $line 1]
						incr vio_cnt
				}
				
				if {$vio_value < $vio_wns} {
						set vio_wns $vio_value
						set vio_constrain $vio_constrain_value
				}
		}
		
		puts "${name} -->   WNS: $vio_wns    WNS_CONSTRAIN: $vio_constrain    VIO_NUM: $vio_cnt"
		close $file
}


####
proc report_summary {phase_name pba_mode} {
		report_constraint -all_violators -nosplit > ./constraint_all_violators.${phase_name}.rep
		report_constraint -all_violators -nosplit -max_transition > ./max_transition.${phase_name}.rep
		report_constraint -all_violators -nosplit -max_capacitance > ./max_capacitance.${phase_name}.rep
		redirect -file timing_summary.${phase_name}.rep {proc_qor}
		redirect -file timing_summary.${phase_name}.rep -append {get_violation_summary ./max_transition.${phase_name}.rep}
		redirect -file timing_summary.${phase_name}.rep -append {get_violation_summary ./max_capacitance.${phase_name}.rep}

		if {[regexp exhaustive|path $pba_mode]} {
				report_constraint -all_violators -pba $pba_mode -nosplit > ./constraint_all_violators.${phase_name}.pba.rep
				if {[regexp path $pba_mode]} {
						redirect -file timing_summary.${phase_name}.pba.rep {proc_qor -pba_path}
				} else {
						redirect -file timing_summary.${phase_name}.pba.rep {proc_qor -pba}
				}
					redirect -file timing_summary.${phase_name}.pba.rep -append {get_violation_summary ./max_transition.${phase_name}.rep}
					redirect -file timing_summary.${phase_name}.pba.rep -append {get_violation_summary ./max_capacitance.${phase_name}.rep}
		}
}



